package com.bmob.lover.ui.fragment.festival

import android.view.View
import com.bmob.lover.data.model.bean.Background
import com.bmob.lover.ui.adapter.FestivalBgAdapter
import com.bmob.lover.ui.fragment.base.BasePagerFragment
import com.bmob.lover.viewmodel.request.FestivalBgRequestViewModel
import com.chad.library.adapter.base.BaseQuickAdapter
import com.theone.common.constant.BundleConstant
import com.theone.common.ext.bundle
import com.theone.common.ext.getValueNonNull
import com.theone.mvvm.core.data.enum.LayoutManagerType

//  ┏┓　　　┏┓
//┏┛┻━━━┛┻┓
//┃　　　　　　　┃
//┃　　　━　　　┃
//┃　┳┛　┗┳　┃
//┃　　　　　　　┃
//┃　　　┻　　　┃
//┃　　　　　　　┃
//┗━┓　　　┏━┛
//    ┃　　　┃                  神兽保佑
//    ┃　　　┃                  永无BUG！
//    ┃　　　┗━━━┓
//    ┃　　　　　　　┣┓
//    ┃　　　　　　　┏┛
//    ┗┓┓┏━┳┓┏┛
//      ┃┫┫　┃┫┫
//      ┗┻┛　┗┻┛
/**
 * @author The one
 * @date 2021-05-12 10:18
 * @describe TODO
 * @email 625805189@qq.com
 * @remark
 */
class FestivalBgItemFragment private constructor():
    BasePagerFragment<Background, FestivalBgRequestViewModel>() {

    companion object{

        fun newInstance(type:Int) = FestivalBgItemFragment().bundle {
            putInt(BundleConstant.TYPE,type)
        }
    }

    val mType:Int by getValueNonNull(BundleConstant.TYPE)

    override fun initData() {
        mTableName = "FestivalBg$mType"
        getViewModel().type = mType
        super.initData()
    }

    override fun getItemSpace(): Int = 10

    override fun getSpanCount(): Int = 3

    override fun getLayoutManagerType(): LayoutManagerType = LayoutManagerType.GRID

    override fun createAdapter(): BaseQuickAdapter<Background, *> = FestivalBgAdapter()

    override fun onItemClick(adapter: BaseQuickAdapter<*, *>, view: View, position: Int) {
        val item = adapter.getItem(position) as Background
        startFragment(FestivalBgListFragment.newInstance(item))
    }

}